from flask import Flask
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()


def init_databases(app: Flask):
    db.init_app(app)
    with app.app_context():
        try:
            db.engine.connect()
        except Exception as e:
            exit(f"数据库连接失败{e}")
